# Create your views here.
from django.http.response import HttpResponse
from firepark_mqtt.mqtt_ser import mqtt_loop


def start_mqtt(request):
    if request.method == "GET":
        try:
            mqtt_loop()
            return HttpResponse("ok")
        except Exception as e:
            return HttpResponse("error", repr(e))
    elif request.method == 'POST':
        try:
            mqtt_loop()
            return HttpResponse("ok")
        except Exception as e:
            return HttpResponse("error", repr(e))
